package StudyCode.summary.zipfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetFileCharacterCount {
	public static long getCharacterCount(File inFile, String charSetName) {
		long count = 0;
		FileInputStream fis = null;
		try {
			fis = new FileInputStream(inFile);
			InputStreamReader isr = new InputStreamReader(fis, charSetName);
			int bufsize = 1024;
			char[] chars = new char[bufsize];
			BufferedReader br = new BufferedReader(isr, bufsize);
			int cnt = br.read(chars, 0, bufsize);
			while (cnt >= 0) {
				count += cnt;
				cnt = br.read(chars, 0, bufsize);
			}
		} catch (FileNotFoundException e) {
		} catch (IOException e) {
		} finally {
			try {
				fis.close();
			} catch (IOException e) {
			}
		}
		return count;
	}
}
